package fac;

import static org.junit.Assert.assertTrue;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that ThirdRobotLaw is not moving (only firing) against an opponent that does not fire back.
 * 
 * @author Chris Fang
 */
public class TestTRLTurretMode extends RobotTestBed {

  double lastVelocityRecorded;

  /**
   * Initiates the battle with SittingDuck and ThirdRobotLaw as the participants.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,fac.ThirdRobotLaw";
  }

  /**
   * This test runs for 10 round.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * After each turn, check to see ThirdRobotLaw's current velocity.
   * 
   * @param event Info about the current state of the battle.
   */
  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    // Get the snapshot of the robot
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];

    lastVelocityRecorded = robot.getVelocity();
  }

  /**
   * After the battle, make sure that the last recorded velocity was zero since the robot should
   * have just sat still and fired upon SittingDuck.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    assertTrue("Check if visited wall", lastVelocityRecorded == 0);
  }

}
